using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace pardusshipcalc
{
    public partial class ErrorForm : Form
    {
        bool expanded = false;

        public ErrorForm(string errorCause, string Component, string CurrAction)
        {
            InitializeComponent();

            string tameVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();            
            string OperatingSystem = System.Environment.OSVersion.ToString();
            string RunTimeVersion = System.Environment.Version.ToString();

            errorDetailsLabel.Text = String.Format("Something went wrong! The error occurred while you were {0}. Make sure that you entered any text correctly. For example, entering any numbers as only numbers - no letters or punctuation." + Environment.NewLine + "" + Environment.NewLine + "If the error persists, then please click the arrow and pass the details to Pigeon - as it's likely you found a bug.", CurrAction);
            errorDetailsTextBox.Text = string.Format("Cause: {0}\r" + Environment.NewLine + "Component: {1}\r" + Environment.NewLine + "On Action: {2}\r" + Environment.NewLine + "Version: {3}\r" + Environment.NewLine + "OS Version: {4}\r" + Environment.NewLine + "Runtime Version: {5}", errorCause, Component, CurrAction, tameVersion, OperatingSystem, RunTimeVersion);
        }

        private void expandButton_Click(object sender, EventArgs e)
        {
            if (expanded != true)
            {
                this.Size = new System.Drawing.Size(397, 360);
                OKButton1.Visible = false;
                expandButton.Image = pardusshipcalc.Properties.Resources.small_arror;
                expanded = true;
            }
            else
            {
                this.Size = new System.Drawing.Size(397, 221);
                OKButton1.Visible = true;
                expandButton.Image = pardusshipcalc.Properties.Resources.rotate_arr_down;
                expanded = false;
            }
        }

        private void copyToClipBoard_Click(object sender, EventArgs e)
        {
            bool error = false;

            try
            {
                Clipboard.SetDataObject(errorDetailsTextBox.Text, true);
            }
            catch (Exception)
            {
                error = true;
                MessageBox.Show("Copying to clipboard failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (!error)
            {
                MessageBox.Show("Successfully copied Error data to clipboard", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void OKButton1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void OKButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
